<template>
	<view class="content">
		<view class="search-box">
			<uni-search-bar @confirm="search" v-model="searchValue" @cancel="cancel" @clear="clear"
				placeholder="输入申请单号">
			</uni-search-bar>
		</view>
		<z-paging ref="paging" v-model="dataList" :default-page-size="row" @onRefresh="onRefresh" @query="getList"
			auto-show-system-loading auto-show-back-to-top>
			<view class="" style="margin-top: 110rpx;"></view>
			<view class="list-box" @click="goto(item)" v-for="(item,index) in dataList" :key="index">
				<view class="top-box">
					<view class="tiem-box">
						申请单号：{{item.nos}}
					</view>
					<view class="status-box">
						<view class="item-box" v-if="item.assessStatus == 0">
							待审计
						</view>
						<view class="item-box" v-if="item.assessStatus == 1">
							审计退回
						</view>
						<view class="item-box" v-if="item.assessStatus == 2">
							待审核
						</view>
						<view class="item-box" v-if="item.assessStatus == 3">
							已拒审
						</view>
						<view class="item-box" v-if="item.assessStatus == 4">
							审核通过
						</view>
					</view>
				</view>
				<view class="xian"></view>
				<view class="title-box">
					{{item.supplierName}}
				</view>
				<view class="info-box">
					<view class="info-item" v-if="item.totalMoney">
						<view class="info-item-title">
							申请金额
						</view>
						<view class="info-item-text">
							{{item.totalMoney}}
						</view>
					</view>
					<view class="info-item" v-if="item.remainMoney">
						<view class="info-item-title">
							剩余金额
						</view>
						<view class="info-item-text">
							{{item.remainMoney}}
						</view>
					</view>
					<view class="info-item" v-if="item.paidMoney">
						<view class="info-item-title">
							支付金额
						</view>
						<view class="info-item-text">
							{{item.paidMoney}}
						</view>
					</view>
				</view>
				<view class="text-box" v-if="item.bankName">
					供应商银行：{{item.bankName}}
				</view>
				<view class="text-box" v-if="item.bankNo">
					供应商行号：{{item.bankNo}}
				</view>
				<view class="text-box" v-if="item.accountNo">
					供应商账号：{{item.accountNo}}
				</view>
				<view class="xian"></view>
				<view class="bnt-box">
					<view class="bnt-big-box">
						<view class="bnt" @click.stop="goto3(item)">
							上传发票
						</view>
						<view class="bnt" @click.stop="goto2(item)">
							查看明细
						</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import config from '@/config'
	import {
		listassessStatus,
		payApplyEdit,
		payApplyAudit,
		payApplyAssess
	} from "@/api/system/index"
	const baseUrl = config.baseUrl
	export default {
		data() {
			return {
				baseUrl: config.baseUrl,
				status: '',
				signImg: '',
				inputValue: '',
				infoItem: {},
				text: '',
				row: 10,
				tabList: [],
				dataList: [],
				searchValue: ''
			}
		},
		onLoad() {
			if (this.checkPermi(['develop:auditPass:list'])) {
				this.tableIndex = 2
			}
		},
		onShow() {
			this.signImg = uni.getStorageSync('signImg')
		},
		methods: {
			// 上传发票
			goto3(e) {
				uni.navigateTo({
					url: '/pagesA/addInvoice/add/index?id=' + e.id
				})
			},
			// 当页面滚动到底部事件被触发
			onReachBottom() {
				// 通知z-paging滚动到底部了，z-paging会进行相应的处理，例如加载更多数据
				this.$refs.paging.pageReachBottom();
			},
			// 下拉刷新被触发
			onRefresh() {
				// 告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					this.$tools.toast('刷新成功～')
				}, 500)
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
			getList(pageNum, pageSize) {
				// this.$refs.paging.complete(false);
				listassessStatus({
					pageNum,
					pageSize,
					nos: this.searchValue
				}).then(res => {
					console.log(res, '这是什么')
					this.$refs.paging.complete(res.rows);
				})
			},
			inputDialogToggle(item, e) {
				uni.navigateTo({
					url: '/pagesA/sign/sign'
				})
				// this.infoItem = item
				// this.infoItem.assessOpinion = ''
				// this.text = e
				// this.$refs.inputDialog.open()
			},
			inputDialogToggle1(item, e) {
				this.infoItem = item
				this.infoItem.assessOpinion = ''
				this.text = e
				this.$refs.inputDialog1.open()
			},
			goto(item) {
				uni.navigateTo({
					url: '/pagesA/invoice/details/index?id=' + item.id
				})
			},
			goto2(item) {
				uni.navigateTo({
					url: '/pagesA/invoice/commodity/index?id=' + item.id
				})
			},
			search(res) {
				this.$refs.paging.reload()
			},

		}

	}
</script>

<style lang="scss">
	.center-box {
		width: 520rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding-top: 50rpx;

		.title-box {
			font-size: 32rpx;
			color: #333333;
			text-align: center;
			padding: 0rpx 100rpx 30rpx;
			border-bottom: 1px solid #F0F0F0;
		}

		.text-box {
			font-size: 28rpx;
			color: #999;
			// text-align: center;
			padding: 30rpx;
			display: flex;
			align-items: center;
		}

		.bottom-box {
			border-top: 2rpx solid #F0F0F0;
			display: flex;
			align-items: center;

			.cancel-box {
				width: 260rpx;
				height: 95rpx;
				font-size: 32rpx;
				text-align: center;
				line-height: 95rpx;
				color: #333333;
				border-right: 2rpx solid #F0F0F0;
			}

			.confirm-box {
				width: 260rpx;
				height: 95rpx;
				background: #2979FF;
				text-align: center;
				line-height: 95rpx;
				font-weight: bold;
				font-size: 32rpx;
				color: #FFFFFF;
				border-bottom-right-radius: 16rpx;
			}
		}
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-left: 20rpx;
		padding-right: 20rpx;

		.table-box {
			width: 750rpx;
			position: sticky;
			top: 0;
			z-index: 2;
			background: #ffffff;
			display: flex;
			justify-content: space-around;

			.table {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				display: flex;
				flex-direction: column;
				align-items: center;

				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
				}
			}

			.tableChange {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #333333;
				display: flex;
				flex-direction: column;
				align-items: center;

				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
					background: #8295BC;
				}
			}
		}

		.search-box {
			z-index: 99;
			width: 750rpx;
			height: 103rpx;
			background: #FFFFFF;
		}

		.list-box {
			padding-left: 20rpx;
			padding-right: 20rpx;
			margin-top: 20rpx;
			border-radius: 8rpx;
			background: #FFF;

			.top-box {
				display: flex;
				align-items: center;
				padding: 20rpx 0rpx;

				.tiem-box {
					color: #999;
					font-size: 24rpx;
				}

				.status-box {
					margin-left: auto;
					display: flex;
					align-items: center;

					.item-box {
						padding: 4rpx 12rpx;
						height: 42rpx;
						border-radius: 10rpx;
						background: #F5F7FB;
						color: #8295BC;
						font-size: 24rpx;
					}
				}
			}

			.xian {
				width: 662rpx;
				border-bottom: 1px solid #EAEAEA;
			}

			.title-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.info-box {
				display: flex;
				align-items: center;
				border-radius: 8rpx;
				background: #F5F7FB;
				padding-top: 10rpx;
				padding-bottom: 10rpx;

				.info-item {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.info-item-title {
						color: #999;
						font-size: 24rpx;
					}

					.info-item-text {
						margin-top: 8rpx;
						color: #333;
						font-size: 28rpx;
						font-weight: bold;
					}
				}
			}

			.text-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #999;
				font-size: 24rpx;
			}

			.bnt-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;

				.bnt-big-box {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					.bnt {
						margin-right: 20rpx;
						display: flex;
						align-items: center;
						border-radius: 10rpx;
						background: #F5F7FB;
						padding: 15rpx 20rpx 15rpx 20rpx;
						color: #4D8987;
						font-size: 24rpx;
					}
				}
			}
		}
	}
</style>